package com.heima.mapper;

import com.github.pagehelper.Page;
import com.heima.annotation.AutoFill;
import com.heima.dto.InsertBusinessDto;
import com.heima.dto.OpportunityDto;
import com.heima.dto.OpportunitySelectDto;
import com.heima.dto.pagedto.PageOpportunityDto;
import com.heima.enumeration.OperationType;
import com.heima.vo.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OpportunityMapper {

    /**
     * 商机分页查询
     * @param dto
     * @return
     */
    Page<OpportunityVo> queryOpportunity(PageOpportunityDto dto);

    /**
     * 新增商机
     * @param dto
     */
    @AutoFill(OperationType.INSERT)
    void insertBusiness(InsertBusinessDto dto);

    /**
     * 根据id查询商机
     * @param id
     * @return
     */
    @Select("select * from tb_opportunity where id = #{id}")
    BusinessInfoVo findBusinessById(Integer id);

    /**
     * 获取商机详情
     * @param businessId
     * @return
     */
    @Select("select * from tb_opportunity where id = #{businessId} ")
    BusinessInfoVo businessIdListVo(Integer businessId);

    /**
     * 获取商检历史沟通记录
     * @param businessId
     * @return
     */
    @Select("select * from tb_opportunity_track where business_id = #{businessId}")
    List<BusinessIdInfoVo> businessIdInfoVo(Integer businessId);

    /**
     * 修改
     * @param dto
     */
    void updateBusiness(OpportunityDto dto);

    /**
     * 插入新的商机跟进
     * @param bii
     */
    void insertTrace(BusinessIdInfoVo bii);

    /**
     * 商机池分页查询
     * @param dto
     * @return
     */
    Page<OpportunityVo> queryPool(PageOpportunityDto dto);

    /**
     * 商机分配
     * @param opportunitySelectDto
     * @param assignBy
     */
    void assignment(OpportunitySelectDto opportunitySelectDto, String assignBy);
}
